package com.journal.book.service.impl;

import java.util.List;
import com.journal.common.utils.DateUtils;
import com.journal.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.journal.book.mapper.BookShelfInfoMapper;
import com.journal.book.domain.BookShelfInfo;
import com.journal.book.service.IBookShelfInfoService;

/**
 * bookService业务层处理
 *
 * @author ruoyi
 * @date 2025-11-08
 */
@Service
public class BookShelfInfoServiceImpl implements IBookShelfInfoService
{
    @Autowired
    private BookShelfInfoMapper bookShelfInfoMapper;


    @Override
    public boolean bachAdd(List<BookShelfInfo> bookShelfInfos) {
        for (BookShelfInfo bookShelfInfo : bookShelfInfos) {
            bookShelfInfo.setCreateBy("莫彬");
            bookShelfInfoMapper.insertBookShelfInfo(bookShelfInfo);
        }
        return true;
    }

    /**
     * 查询book
     *
     * @param id book主键
     * @return book
     */
    @Override
    public BookShelfInfo selectBookShelfInfoById(Long id)
    {
        return bookShelfInfoMapper.selectBookShelfInfoById(id);
    }

    /**
     * 查询book列表
     *
     * @param bookShelfInfo book
     * @return book
     */
    @Override
    public List<BookShelfInfo> selectBookShelfInfoList(BookShelfInfo bookShelfInfo)
    {
        return bookShelfInfoMapper.selectBookShelfInfoList(bookShelfInfo);
    }

    /**
     * 新增book
     *
     * @param bookShelfInfo book
     * @return 结果
     */
    @Override
    public int insertBookShelfInfo(BookShelfInfo bookShelfInfo)
    {
        bookShelfInfo.setCreateTime(DateUtils.getNowDate());
        bookShelfInfo.setCreateBy(SecurityUtils.getLoginUser().getUser().getNickName());
        return bookShelfInfoMapper.insertBookShelfInfo(bookShelfInfo);
    }

    /**
     * 修改book
     *
     * @param bookShelfInfo book
     * @return 结果
     */
    @Override
    public int updateBookShelfInfo(BookShelfInfo bookShelfInfo)
    {
        bookShelfInfo.setUpdateTime(DateUtils.getNowDate());
        return bookShelfInfoMapper.updateBookShelfInfo(bookShelfInfo);
    }

    /**
     * 批量删除book
     *
     * @param ids 需要删除的book主键
     * @return 结果
     */
    @Override
    public int deleteBookShelfInfoByIds(Long[] ids)
    {
        return bookShelfInfoMapper.deleteBookShelfInfoByIds(ids);
    }

    /**
     * 删除book信息
     *
     * @param id book主键
     * @return 结果
     */
    @Override
    public int deleteBookShelfInfoById(Long id)
    {
        return bookShelfInfoMapper.deleteBookShelfInfoById(id);
    }
}
